package com.chinawlx.wlxteacher.utils;

import android.database.sqlite.SQLiteDatabase;

import com.chinawlx.wlxteacher.DaoMaster;
import com.chinawlx.wlxteacher.DaoSession;
import com.chinawlx.wlxteacher.base.WLXApplication;
import com.chinawlx.wlxteacher.wlx_authDao;
import com.chinawlx.wlxteacher.wlx_configDao;
import com.chinawlx.wlxteacher.wlx_fileDao;
import com.chinawlx.wlxteacher.wlx_gradeDao;
import com.chinawlx.wlxteacher.wlx_grade_noticeDao;
import com.chinawlx.wlxteacher.wlx_grade_timelineDao;
import com.chinawlx.wlxteacher.wlx_homeworkDao;
import com.chinawlx.wlxteacher.wlx_homework_commentDao;
import com.chinawlx.wlxteacher.wlx_homework_statisticsDao;
import com.chinawlx.wlxteacher.wlx_scheduleDao;
import com.chinawlx.wlxteacher.wlx_schedule_changeDao;
import com.chinawlx.wlxteacher.wlx_schedule_scoreDao;
import com.chinawlx.wlxteacher.wlx_statistics_student_classDao;
import com.chinawlx.wlxteacher.wlx_studentDao;
import com.chinawlx.wlxteacher.wlx_student_order_detailDao;
import com.chinawlx.wlxteacher.wlx_student_studyDao;
import com.chinawlx.wlxteacher.wlx_userDao;


/**
 * 作者:吴名
 * 时间:16/8/8
 * 描述:获取GreenDao数据库操作对象
 */
public class WLXGreenDaoUtil {

    private static wlx_authDao mAuthDao;
    private static wlx_configDao mConfigDao;
    private static wlx_studentDao mStudentDao;
    private static wlx_userDao mUserDao;
    private static wlx_gradeDao mGradeDao;
    private static wlx_homeworkDao mHomeWorkDao;
    private static wlx_homework_commentDao mHomeworkCommentDao;
    private static wlx_scheduleDao mScheduleDao;
    private static wlx_grade_noticeDao mGradeNoticeDao;
    private static wlx_student_order_detailDao mStudentOrderDetaiDao;
    private static wlx_student_studyDao mStudentStudyDao;
    private static wlx_grade_timelineDao mGradeTimeLineDao;
    private static wlx_fileDao mFileDao;
    private static wlx_statistics_student_classDao mStatisticsStudentDao;
    private static wlx_schedule_scoreDao mScheduleScoreDao;
    private static wlx_schedule_changeDao mScheduleChangeDao;
    private static wlx_homework_statisticsDao mHomeworkStatisticsDao;


    public static wlx_authDao getAuthDao() {
        if (mAuthDao == null) {
            //初始化数据库
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_auth", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            mAuthDao = daoSession.getWlx_authDao();
        }
        return mAuthDao;
    }

    public static wlx_userDao getUserDao() {
        if (mUserDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_user", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            // 数据库的 CRUD 操作都是通过此对象来进行
            mUserDao = daoSession.getWlx_userDao();
        }
        return mUserDao;
    }

    /**
     * wlx_grade
     *
     * @return
     */
    public static wlx_gradeDao getGradeDao() {
        if (mGradeDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_grade", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            // 数据库的 CRUD 操作都是通过此对象来进行
            mGradeDao = daoSession.getWlx_gradeDao();
        }
        return mGradeDao;

    }

    /**
     * wlx_homework
     *
     * @return
     */

    public static wlx_homeworkDao getHomeWorkDao() {
        if (mHomeWorkDao == null) {

            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_homework", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            // 数据库的 CRUD 操作都是通过此对象来进行
            mHomeWorkDao = daoSession.getWlx_homeworkDao();
        }

        return mHomeWorkDao;
    }

    /**
     * wlx_homework_comment
     *
     * @return
     */
    public static wlx_homework_commentDao getHomeWorCommentkDao() {
        if (mHomeworkCommentDao == null) {

            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_homework_comment", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            // 数据库的 CRUD 操作都是通过此对象来进行
            mHomeworkCommentDao = daoSession.getWlx_homework_commentDao();
        }

        return mHomeworkCommentDao;
    }

    /**
     * wlx_schedule
     *
     * @return
     */
    public static wlx_scheduleDao getScheduleDao() {
        if (mScheduleDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_schedule", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            // 数据库的 CRUD 操作都是通过此对象来进行
            mScheduleDao = daoSession.getWlx_scheduleDao();
        }
        return mScheduleDao;
    }

    /**
     * wlx_grade_notice
     *
     * @return
     */
    public static wlx_grade_noticeDao getGradeNoticeDao() {
        if (mGradeNoticeDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_grade_notice", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            // 数据库的 CRUD 操作都是通过此对象来进行
            mGradeNoticeDao = daoSession.getWlx_grade_noticeDao();
        }

        return mGradeNoticeDao;
    }

    /**
     * wlx_student
     *
     * @return
     */
    public static wlx_studentDao getStudentDao() {
        if (mStudentDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_student", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            // 数据库的 CRUD 操作都是通过此对象来进行
            mStudentDao = daoSession.getWlx_studentDao();
        }

        return mStudentDao;
    }

    /**
     * wlx_student_order_detail
     *
     * @return
     */
    public static wlx_student_order_detailDao getStudentOrderDetailDao() {

        if (mStudentOrderDetaiDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_student_order_detail", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            // 数据库的 CRUD 操作都是通过此对象来进行
            mStudentOrderDetaiDao = daoSession.getWlx_student_order_detailDao();
        }
        return mStudentOrderDetaiDao;
    }

    /**
     * wlx_config
     *
     * @return
     */
    public static wlx_configDao getConfigDao() {
        if (mConfigDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_config", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            mConfigDao = daoSession.getWlx_configDao();
        }
        return mConfigDao;
    }

    /**
     * wlx_student_study
     *
     * @return
     */
    public static wlx_student_studyDao getStudentStudyDao() {
        if (mStudentStudyDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_student_study", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            mStudentStudyDao = daoSession.getWlx_student_studyDao();
        }
        return mStudentStudyDao;
    }

    /**
     * wlx_file表
     *
     * @return
     */
    public static wlx_fileDao getFileDao() {
        if (mFileDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_file", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            mFileDao = daoSession.getWlx_fileDao();
        }
        return mFileDao;
    }

    /**
     * wlx_grade_timeline表
     */
    public static wlx_grade_timelineDao getGradeTimeLineDao() {
        if (mGradeTimeLineDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_grade_timeline", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            mGradeTimeLineDao = daoSession.getWlx_grade_timelineDao();
        }
        return mGradeTimeLineDao;
    }

    /**
     * wlx_statistics_student_class表
     */
    public static wlx_statistics_student_classDao getStatisticsStudentDao() {
        if (mStatisticsStudentDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_statistics_student_class", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            mStatisticsStudentDao = daoSession.getWlx_statistics_student_classDao();
        }
        return mStatisticsStudentDao;
    }

    /**
     * wlx_statistics_student_class表
     */
    public static wlx_schedule_scoreDao getScheduleScoreDao() {
        if (mScheduleScoreDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_schedule_score", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            mScheduleScoreDao = daoSession.getWlx_schedule_scoreDao();
        }
        return mScheduleScoreDao;
    }

    /**
     * wlx_statistics_student_class表
     */
    public static wlx_schedule_changeDao getScheduleChangeDao() {
        if (mScheduleChangeDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_schedule_change", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            mScheduleChangeDao = daoSession.getWlx_schedule_changeDao();
        }
        return mScheduleChangeDao;
    }

    /**
     * wlx_homework_statistics表
     */
    public static wlx_homework_statisticsDao getHomeworkStatisticsDao() {
        if (mHomeworkStatisticsDao == null) {
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(WLXApplication
                    .myApplication, "wlx_homework_statistics", null);
            SQLiteDatabase db = helper.getWritableDatabase();
            DaoMaster daoMaster = new DaoMaster(db);
            DaoSession daoSession = daoMaster.newSession();
            mHomeworkStatisticsDao = daoSession.getWlx_homework_statisticsDao();
        }
        return mHomeworkStatisticsDao;
    }
}
